package com.appium.testng;

import io.appium.java_client.android.AndroidDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.Assert;
import org.testng.annotations.*;

import com.appium.base.BaseTest;

import java.net.URI;
import java.net.URISyntaxException;

public class AndroidCreateWebSessionTest extends BaseTest {
	private AndroidDriver<WebElement> driver;

	@BeforeClass
	public void setUp() {
		DesiredCapabilities capabilities = new DesiredCapabilities();
		capabilities.setCapability("deviceName", "Android Emulator");
		capabilities.setCapability("browserName", "Chrome");
		driver = new AndroidDriver<WebElement>(getServiceUrl(), capabilities);
	}

	@AfterClass
	public void tearDown() {
		driver.quit();
	}

	@Test()
	public void testCreateWebSession() throws URISyntaxException {
		driver.get(new URI("http://www.google.com").toString());
		String title = driver.getTitle();
		Assert.assertEquals(title, "Google");
	}
}
